/**
 * 				DataManager.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	data
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.dataClasses;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import mochito.dataClasses.musicItem.MusicItem;

/**
 * @author  bin04017
 */
public class DataManager extends UnicastRemoteObject{

	/**
	 * 
	 */
	private static final long serialVersionUID = 9212755760239153846L;
	/**
	 */
	private Map<String, MusicItem> musicSet = new HashMap<String, MusicItem>();
	
	public DataManager() throws RemoteException {
		super();
	}
	public MusicItem getMusicItem(String name){
		MusicItem item = (MusicItem)this.getMusicSet().get(name);
		return item;
	}
	public void addMusicItem(MusicItem musicItem){
		this.getMusicSet().put(musicItem.getName(), musicItem);
	}
	/**
	 * @return  the musicSet
	 */
	public Map<String, MusicItem> getMusicSet() {
		return musicSet;
	}
	
	/**
	 * @param musicSet  the musicSet to set
	 */
	protected void setMusicSet(Map<String, MusicItem> musicSet) {
		this.musicSet = musicSet;
	}
	public Set<String> getMusicItems() {
		Set<String> items = new HashSet<String>();
		items.addAll(getMusicSet().keySet());		
		return items;
	}
	public void removeMusicItem(MusicItem item) {
		this.musicSet.remove(item.getName());		
	}
}
